package chapter10.ClodeBlock;

import jdk.nashorn.internal.ir.CallNode;

//代码块
// 1.对相同的代码进行抽取
// 2.这样不管调用哪个构造器，都会先调用代码块中的内容
// 3.代码块的调用顺序，高于构造器。
public class codeBlock {
    public static void main(String[] args) {
        Movie movie = new Movie("你好");
        Movie movie1 = new Movie("你好");
    }
}
class Movie{
    private String name;
    private double price;
    private String director;
    {
        System.out.println("电影屏幕打开");
        System.out.println("广告开始");
        System.out.println("电影开始");
    };

    public Movie(String name)  {
        this.name = name;
    }

    public Movie(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String director) {
        this.name = name;
        this.price = price;
        this.director = director;
    }
}